package com.qf.utils;

import java.math.BigInteger;
import java.security.MessageDigest;

/**
 * @author wgy
 * @version V1.0
 * @project gp12_xiaomi
 * @package com.qf.utils
 * @description: ${TODO}
 * @date 2022/6/22 15:57
 */
public class Md5 {
    public static void main(String[] args) {
        String s = md5("123456");
        System.out.println(s);
    }
    public static String md5(String s){
        try {
            //创建Md5摘要算法对象
            MessageDigest md5=MessageDigest.getInstance("MD5");
            //更新
            md5.update(s.getBytes("utf-8"));
            //获取加密数据
            byte[] digest = md5.digest();
            //把字节数组转成字符串
            return new BigInteger(1, digest).toString(16);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
